## ---- r load_custom_ggplot_themes

########################################
## Custom ggplot theme based on cowplot
########################################

require(cowplot)

# theme_book <- function() {
#     theme_cowplot() %+replace%
#         theme(
#             panel.grid.major = element_line(linewidth = .5, color = "grey90"),
#             strip.text = element_text(size=9, lineheight=0.5),
#             text = element_text(family = "Verdana")
#         ) 
# }

# pm2 <- function(mod, vars, legend = TRUE, title = "") {
#   plot_model(mod,
#            show.legend = legend,
#            title = title,
#            type = "pred",
#            terms = vars) +
#     theme(legend.pos = "bottom")
# }


theme_book <- function() {
    theme_minimal() %+replace% 
        theme(
            text = element_text(family = "Verdana"),
            axis.title.y = element_text(margin = margin(r = 12), angle = 90, vjust = 0.5), 
            axis.title.x = element_text(margin = margin(t = 8)) 
        )
    }

theme_book_bottom <- function() {
    theme_cowplot() %+replace%
        theme(
            panel.grid.major = element_line(linewidth = .5, color = "grey90"),
            strip.text = element_text(size=9, lineheight=0.5),
            legend.position = "bottom"
        ) 
}
########################################
## Custom ggplot theme based on cowplot
########################################

require(cowplot)

theme_apsr <- theme_cowplot() +
    theme(
        panel.grid.major = element_line(linewidth = .5, color = "grey90"),
        axis.text = element_text(size = 9),
        strip.text = element_text(size=9, lineheight=0.5)
    )

theme_apsr_grid <- theme_apsr %+replace%
    theme(
        panel.grid.minor = element_line(linewidth = .25, color = "grey90")
        #panel.grid.minor = element_line(linewidth = .25, color = "grey90")
        
    ) 

theme_apsr_coef <- theme_apsr_grid %+replace%
    theme(
        plot.title = element_text(size = 18),
        text = element_text(size = 18),
        axis.text.x = element_text(
            angle = 0,
            hjust = 0,
            vjust = 0
        )
    )
